//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#if _MSC_VER > 1000
#pragma once
#endif

#if !defined(__CKTFSDIRSTRENUMERATOR_H__)
#define __CKTFSDIRSTRENUMERATOR_H__

#define _NO_CKTFSDIRSTRENUMERATOR_CLASSOBJECT_
#include "_CKtfsDirStrEnumerator.h"
#include "CBasicDirectory.h"

#include <fatfile.h>
#include <fat.h>

class CKtfsDirStrEnumerator : public _CKtfsDirStrEnumerator
{
public:
    CARAPI Current(
        /* [out] */ WStringBuf * pPsa);

    CARAPI MoveNext(
		/* [out] */ Boolean* pSucceeded);

    CARAPI Reset();

    CKtfsDirStrEnumerator(
            IBasicDirectory  * const pBasicDirectory,
            CFatFile * const pFatFile);

    ~CKtfsDirStrEnumerator();

private:
    CKtfsDirStrEnumerator() {}

    IBasicDirectory *m_pBasicDirectory;
    CFatFile *m_pCFatFile;

    wchar_t m_current[VSE_MAX_NAME + 1];
};

inline CKtfsDirStrEnumerator::CKtfsDirStrEnumerator(
    IBasicDirectory *const pBasicDirectory,
    CFatFile *const pCFatFile)
{
    m_pBasicDirectory = pBasicDirectory;
    m_pCFatFile = pCFatFile;
    m_pCFatFile->f_pos = 0;
    m_current[0] = L'\0';
    m_pBasicDirectory->AddRef();
    m_pCFatFile->AddRef();
}

inline CKtfsDirStrEnumerator::~CKtfsDirStrEnumerator()
{
    if (m_pBasicDirectory) {
        m_pBasicDirectory->Release();
    }
    if (m_pCFatFile) {
        m_pCFatFile->Release();
    }
}

#endif //!(__CDIRSTRENUMERATOR_H__)
